/**
 * 
 */
package com.flux.tms.tm${bean.numMain}srv.t${bean.numMain}${bean.numSub}.impl.service;

import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import com.flux.tms.tm${bean.numMain}srv.t${bean.numMain}${bean.numSub}.${bean.javaFlieName}CVal;
import com.flux.tms.tm${bean.numMain}srv.t${bean.numMain}${bean.numSub}.impl.dao.${bean.javaFlieName}Dao;
import com.flux.tms.tm${bean.numMain}srv.t${bean.numMain}${bean.numSub}.impl.dao.Update${bean.javaFlieName}Dao;
import com.flux.scev6.constant.CommonCVal;
import com.flux.scev6.dbopr.BaseDao;
import com.flux.scev6.login.model.LoginInfoObj;
import com.flux.scev6.extendopr.api.StdBizExtExecuteService;
import com.flux.scev6.exception.RowDataException;
import com.flux.scev6.dbopr.model.ResultObj;

/**
 * 
 * T${bean.numMain}${bean.numSub} ${bean.notesMain} -- ${bean.notesSub}   -- srv 更新数据   Service 实现
 * 
 * T${bean.numMain}${bean.numSub} ${bean.notesSub}
 * 
 * <p>
 * 创建时间：${bean.dayTime}
 * <p>
 * 
 * <p>
 * 修改时间：${bean.dayTime}
 * <p>
 * 
 * @author ${bean.author}
 * 
 * @version V1.0.0
 *
 */
@Service
@Transactional(rollbackFor=Exception.class)
public class Update${bean.javaFlieName}Service {

	/**
	 * V100(${bean.numTime}) ${bean.author} 初版。
	 */
	@SuppressWarnings("unused")
	private static String verNum = "V100(${bean.numTime})";// 版本号

	@Autowired
	private ${bean.javaFlieName}Dao ${bean.javaFlieName}Dao;
	@Autowired
	private Update${bean.javaFlieName}Dao update${bean.javaFlieName}Dao;
	@Autowired
    private StdBizExtExecuteService stdBizExtExecuteService;

	/**
	 * 更新  ${bean.notesSub}    数据
	 * 
	 * 
	 * @date ${bean.dayTime}
	 * 
	 * @param loginInfoObj 登录信息
	 * @param bizDataMap  提交参数 
	 * @return
	 */
	public Map<String, Object> get${bean.javaFlieName}(LoginInfoObj loginInfoObj, Map<String, String> bizDataMap) {
		return ${bean.javaFlieName}Dao.get${bean.javaFlieName}Info(loginInfoObj, bizDataMap);
	}

	/**
	 * 更新  ${bean.notesSub}    数据
	 * 
	 * 
	 * @date ${bean.dayTime}
	 * 
	 * @param loginInfoObj 登录信息
	 * @param bizDataMap  提交参数 
	 * @return
	 */
	public Map<String, Object> get${bean.javaFlieName}(LoginInfoObj loginInfoObj, Map<String, String> bizDataMap,
			String otherReturnFields) {
		return ${bean.javaFlieName}Dao.get${bean.javaFlieName}Info(loginInfoObj, bizDataMap, otherReturnFields);
	}

	
	/**
	 * 提交数据 (这里的所有操作放在一个事务中，抛出异常将会触发事务回滚操作)
	 *
	 * @date ${bean.dayTime}
	 * 
	 * @param loginInfoObj
	 * @param bizDataMap
	 * @param whereDataMap
	 * @return
	 * @throws Exception
	 */
	public ResultObj postData(LoginInfoObj loginInfoObj, Map<String, String> bizDataMap,
			Map<String, String> whereDataMap) throws Exception {
		// throws RuntimeException
	    ResultObj resultObj = new ResultObj();
		// ==================================================================================
		// ==================================================================================
	    // 20181201 jingdy 调用标准业务功能扩展逻辑 - 前置操作  EDT   DEL
        String functionId = ${bean.javaFlieName}CVal.FUNC_ID;
        String actionCode = "EDT"; // 默认使用 BSM_FUNCTION_ACTION.actionId 的值
        String extendType = CommonCVal.STDBIZ_EXT_TYPE_PRE_IN; // 前置操作
        stdBizExtExecuteService.executeInTrans(loginInfoObj, bizDataMap, functionId, actionCode, extendType);
		// ==================================================================================
		String ${bean.pk01} = bizDataMap.get(${bean.javaFlieName}CVal.KEYNAME_${(bean.pk01)?upper_case});
		String ${bean.pk02} = bizDataMap.get(${bean.javaFlieName}CVal.KEYNAME_${(bean.pk02)?upper_case});
	<#if (bean.pk03)!="">
		String ${bean.pk03} = bizDataMap.get(${bean.javaFlieName}CVal.KEYNAME_${(bean.pk03)?upper_case});
	</#if>
	bizDataMap.remove(${bean.javaFlieName}CVal.KEYNAME_${(bean.pk01)?upper_case});// 不更新主键值
		bizDataMap.remove(${bean.javaFlieName}CVal.KEYNAME_${(bean.pk02)?upper_case});// 不更新主键值
	<#if (bean.pk03)!="">
		bizDataMap.remove(${bean.javaFlieName}CVal.KEYNAME_${(bean.pk03)?upper_case});// 不更新主键值
	</#if>
	<#if (bean.pk04)!="">
		bizDataMap.remove(${bean.javaFlieName}CVal.KEYNAME_${(bean.pk04)?upper_case});// 不更新主键值
	</#if>
	// ==================================================================================
		// ==================================================================================
		// ==================================================================================
		// 执行更新操作()
		int updatedRowsNum = update${bean.javaFlieName}Dao.update${bean.javaFlieName}1H(loginInfoObj, bizDataMap, whereDataMap);
		if (updatedRowsNum <= 0) {
			throw new RowDataException(${bean.javaFlieName}CVal.FUNC_ID + ${bean.javaFlieName}CVal.ERRID_542,
					"No DepartmentInfo1H Data[" + ${bean.pk01} + "]" + ",[" + ${bean.pk02} + "]");
		}
		// ==================================================================================
		// ==================================================================================
		// ==================================================================================
		// ==================================================================================
		// ==================================================================================
		bizDataMap.put(${bean.javaFlieName}CVal.KEYNAME_${(bean.pk01)?upper_case}, ${bean.pk01});
		bizDataMap.put(${bean.javaFlieName}CVal.KEYNAME_${(bean.pk02)?upper_case}, ${bean.pk02});
	<#if (bean.pk03)!="">
		bizDataMap.put(${bean.javaFlieName}CVal.KEYNAME_${(bean.pk03)?upper_case}, ${bean.pk03});
	</#if>
	<#if (bean.pk04)!="">
		bizDataMap.put(${bean.javaFlieName}CVal.KEYNAME_${(bean.pk04)?upper_case}, ${bean.pk04});
	</#if>
		// 20181201 jingdy 调用标准业务功能扩展逻辑 - 后置操作
        extendType = CommonCVal.STDBIZ_EXT_TYPE_POST_IN; // 后置操作
        stdBizExtExecuteService.executeInTrans(loginInfoObj, bizDataMap,functionId, actionCode, extendType);
		// 操作成功
		resultObj.setCodeValueOK();
		return resultObj;
	}

}
